﻿using System;
using System.IO;
using System.Web.Hosting;
using System.Web.UI;
using MPBlog.Core;

namespace MPBlog.Admin
{
    public partial class Login : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //取出后台管理的主题，然后返回该主题下的登录界面
            string theme = Request.QueryString["theme"];
            if (string.IsNullOrEmpty(theme))
            {
                Server.Transfer(string.Format("{0}admin/themes/{1}/login.aspx", Utils.RelativeWebRoot, Blog.AdminTheme));
            }
            else
            {
                string file = string.Format("~/Admin/Themes/{0}/login.aspx", theme);
                bool fileExits = File.Exists(HostingEnvironment.MapPath(file));
                if (fileExits)
                {
                    Server.Transfer(string.Format("{0}/admin/themes/{1}/login.aspx", Utils.RelativeWebRoot, theme));
                }
                else
                {
                    Server.Transfer(string.Format("{0}/admin/themes/{1}/login.aspx", Utils.RelativeWebRoot,
                                                  Blog.AdminTheme));
                }
            }
            base.OnPreInit(e);
        }


    }
}